﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Repository;
using Models.Models;
using System.Data.Entity;
using Database;
using System.Diagnostics;


namespace TestProjectRepository
{
    [TestClass]
    public class RepositoryTest
    {
        [TestMethod]
        public void Repository_WhenInvoke_GetAll()
        {
            // Arrange
            DbContext dataContext = new CompanyContext();

            Employee employee = new Employee();
            employee.ID = 1;
            employee.FirstName = "Crisma Victoria";
            employee.LastName = "Tanola";

            var repo = new Repo<Employee>(dataContext);        

            // Act
            repo.Insert(employee);

            // Assert
            IEnumerable<Employee> employees = repo
                  .GetAll()
                  .Where(e => e.ID == 1);

            foreach (Employee e in employees)
            {
                Assert.AreEqual(1, e.ID);
                Debug.WriteLine(e.FirstName);
            }
        }
    }
}
